package com.ruoyi.daily.service.impl;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.daily.domain.dto.CustomerServiceFiveStarDto;
import com.ruoyi.daily.domain.dto.CustomerServiceFiveStarEchartsDto;
import com.ruoyi.daily.domain.dto.FiveNetworkDto;
import com.ruoyi.daily.domain.vo.FiveStarVo;
import com.ruoyi.daily.mapper.FiveStarManagementMapper;
import com.ruoyi.daily.service.FiveStarManagementService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author cmz
 * @Date 2024-06-17 16:54
 */
@Service
public class FiveStarManagementServiceImpl implements FiveStarManagementService {
    @Resource
    private FiveStarManagementMapper fiveStarManagementMapper;
    @Override
    public R<CustomerServiceFiveStarDto> customerServiceFiveStar(FiveStarVo fiveStarVo) {
        CustomerServiceFiveStarDto customerServiceFiveStarDto = new CustomerServiceFiveStarDto();
        Integer count = 0;
        List<CustomerServiceFiveStarEchartsDto> list = new ArrayList<>();
        String title = "";
        //if (fiveStarVo.getType() == 3){
            list = fiveStarManagementMapper.customerServiceFiveStarEcharts(fiveStarVo.getDate());
            count = fiveStarManagementMapper.selectHqStarRatedCustomerServiceCountbYMonth(fiveStarVo.getDate());
            title = "参评业务员";
        //}
        List<CustomerServiceFiveStarEchartsDto> sortList = new ArrayList<>();
        String[] sort = {"五星","四星","三星","二星","一星"};
        for (String s : sort) {
            for (CustomerServiceFiveStarEchartsDto customerServiceFiveStarEchartsDto : list) {
                if (s.equals(customerServiceFiveStarEchartsDto.getStarLevel())){
                    sortList.add(customerServiceFiveStarEchartsDto);
                }
            }
        }
        customerServiceFiveStarDto.setCount(count);
        customerServiceFiveStarDto.setEchartsList(sortList);
        customerServiceFiveStarDto.setTitle(title);
        return R.ok(customerServiceFiveStarDto);
    }

    @Override
    public R<FiveNetworkDto> network(String month) {
        FiveNetworkDto fiveNetworkDto = new FiveNetworkDto();
        fiveNetworkDto.setName("辽宁盘锦公司");
        fiveNetworkDto.setStarLevel("四星");
        fiveNetworkDto.setScore(82.55);
//        fiveNetworkDto.setScoreCompare(5.1);
        return R.ok(fiveNetworkDto);
    }
}
